#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "rngs.h"

#define DEBUG 0
#define NOISY_TEST 1

// Function being tested: int fullDeckCount(...) {...}

int TfullDeckCount(int player, struct gameState *state, int card)
{
  int x, countA = 0, countB = 0;
  for(x = 0; x < state->handCount[player]; x++){
    if(state->hand[player][x] == card){
      countB++;
    }
  }
  for(x = 0; x < state->deckCount[player]; x++){
    if(state->deck[player][x] == card){
      countB++;
    }
  }
  for(x = 0; x < state->discardCount[player]; x++){
    if(state->discard[player][x] == card){
      countB++;
    }
  }
  countA = fullDeckCount(player, card, state);
  assert(countA == countB);
  return 0;
}


int main()
{
  int x, y, randomPlayer, randomCard;
  struct gameState newGame;
  printf("Now Testing: int fullDeckCount(...) {...}\n");

  SelectStream(2);
  PutSeed((long)14);

  for(x = 0; x < 10; x++){
    for (y = 0; y < sizeof(struct gameState); y++){
      ((char*)&newGame)[y] = Random() * 100;
    }
    randomPlayer = floor(Random() * MAX_PLAYERS);
    randomCard = Random() * 27;
    newGame.whoseTurn = randomPlayer;
    newGame.handCount[randomPlayer] = Random() * MAX_HAND;
    newGame.deckCount[randomPlayer] = Random() * MAX_DECK;
    newGame.discardCount[randomPlayer] = Random() * MAX_PLAYERS;
    TfullDeckCount(randomPlayer, &newGame, randomCard);
  }

  printf("Everything checks out according to this test.\n");

  return 0;
}
